<?php
/************************FoxPHP威客系统************************/
/*                                                            */
/*  FoxPHP.Com (C)2006-2016 FoxPHP Inc.                       */
/*  This is NOT a freeware, use is subject to license terms   */
/*  FoxPHP威客系统是商业软件,使用于商业用途请购买授权         */
/*  V3.0 2016.3                                               */
/*  foxphp@aliyun.com                                         */
/*  http://www.foxphp.com                                     */
/*                                                            */
/**************************************************************/

namespace Register\Controller;
use Think\Controller;
class IndexController extends Controller {
	
	public function indexAction(){
		
		if(C('sitecloseregister')){
			$this->error('网站注册暂时关闭！','/');
			return false;
		}
		
		if($this->uid>0){
			$this->error('您已是会员！','/',3);
			return false;
		}
		
		$this->assign('PATH',array('注册'));
		$this->assign('SEO',array('title'=>'注册','keywords'=>'注册','description'=>'注册'));
		
		$this->display();

	}
    
	public function verifyAction(){
		$id=intval($_GET['id']);
		$memberverify=new \Register\Model\MemberVerifyModel();
		if(!$memberverify->IsMemberVerify(" id=$id AND status!=1 ")){
			$this->error('数据不存在!', '/register');
		}
		$this->assign('id',$id);
		$manage=$memberverify->IsMemberVerify(" id=$id ");
		$this->assign('manage',$manage);
		if($manage['regtype']=='mobile'){
			$verifyname=str_replace(substr($manage['mobile'],3,6),'******',$manage['mobile']);	 
		}else{
			$verifyname=str_replace(substr($manage['email'],0,3),'***',$manage['email']);
		}
		$this->assign('verifyname',$verifyname);
		if (IS_POST && $manage){
			if($memberverify->PostVerify($manage)){
				$memberverify->DeleteMemberVerify(" id=$id ");
				$this->success($memberverify->getSuccess(),'/login');
			}else{
				$this->error($memberverify->getError());
			}
		}else{
			$this->display();
		}
		
	}
}